prepare("select sn from gallery ORDER BY sn DESC LIMIT 1") ; $getlast->execute() ; //if($getlast->rowcount() > 0) //{ $lastid = $getlast->fetchColumn() ; $newid = $lastid + 1 ; //} //else //$newid = 1 ; if(isset($_POST['btnsave'])) { //$username = $_POST['user_name'];// user name //$userjob = $_POST['user_job'];// user email $ds = $_POST['ds']; $title = $_POST['title']; //$model = $_POST['model']; $imgFile = $_FILES['user_image']['name']; $tmp_dir = $_FILES['user_image']['tmp_name']; $imgSize = $_FILES['user_image']['size']; //if(empty($userjob)){ //$errMSG = "Please Enter Picture description."; //} //else if(empty($imgFile)){ $errMSG = "Please Select Image File."; } else { $upload_dir = '../video/'; // upload directory $imgExt = strtolower(pathinfo($imgFile,PATHINFO_EXTENSION)); // get image extension // valid image extensions $valid_extensions = array('mp4', 'ogg', 'avi', 'webM'); // valid extensions // rename uploading image $userpic = rand(1000,1000000).".".$imgExt; // allow valid image file formats if(in_array($imgExt, $valid_extensions)){ // Check file size '5MB' if($imgSize < 25000000) { move_uploaded_file($tmp_dir,$upload_dir.$userpic); } else{ $errMSG = "Sorry, your file is too large."; } } else{ $errMSG = "Sorry, only mp4, ogg, avi, webM files are allowed."; } } // if no error occured, continue .... if(!isset($errMSG)) { $tp = "video" ; $stmt = $DB_con->prepare('INSERT INTO gallery(type,title,ds,image) VALUES(:tp,:tt,:ds,:im)'); //$stmt->bindParam(':uname',$username); //$stmt->bindParam(':itc',$icode); $stmt->bindParam(':tp',$tp); $stmt->bindParam(':tt',$title); $stmt->bindParam(':ds',$ds); $stmt->bindParam(':im',$userpic); if($stmt->execute()) { $successMSG = "new Video succesfully inserted ..."; header("refresh:2;home.php"); // redirects image view page after 5 seconds. } else { $errMSG = "error while inserting...."; } } } ?>